package com.skivingcloud.admin.sys.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.StringJoiner;

/**
 *  实体类。
 *
 * @author skivingcloud
 * @since 2023-08-28
 */
@Table(value = "sys_role")
public class SysRole implements Serializable {

    @Id
    private String id;

    /**
     * 角色名称
     */
    @NotBlank(message = "角色名称不能为空")
    @Size(max = 100, message = "角色名称长度不能超过100")
    @Schema(title = "角色名称")
    private String roleName;

    /**
     * 备注
     */
    @Size(max = 100, message = "备注长度不能超过100")
    @Schema(title = "备注")
    private String remark;

    /**
     * 创建者ID
     */
    private String createUserId;

    /**
     * 创建时间
     */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    /**
     * 修改人
     */
    private String modUserId;

    /**
     * 修改时间
     */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime modTime;

    /**
     * 租户
     */
    @Schema(title = "租户")
    private String tenantId;
    
    /**
     * 租户名称
     */
    @Column(ignore = true)
    private String tenantName;
    
    @Column(ignore = true)
    private String[] resId;
    
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(String createUserId) {
        this.createUserId = createUserId;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public String getModUserId() {
        return modUserId;
    }

    public void setModUserId(String modUserId) {
        this.modUserId = modUserId;
    }

    public LocalDateTime getModTime() {
        return modTime;
    }

    public void setModTime(LocalDateTime modTime) {
        this.modTime = modTime;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }
    
    public String getTenantName(){
        return tenantName;
    }
    
    public void setTenantName(String tenantName){
        this.tenantName = tenantName;
    }
    
    public String[] getResId(){
        return resId;
    }
    
    public void setResId(String[] resId){
        this.resId = resId;
    }
    
    @Override
    public String toString(){
        return new StringJoiner(", ", SysRole.class.getSimpleName() + "[", "]")
                .add("id='" + id + "'")
                .add("roleName='" + roleName + "'")
                .add("remark='" + remark + "'")
                .add("createUserId='" + createUserId + "'")
                .add("createTime=" + createTime)
                .add("modUserId='" + modUserId + "'")
                .add("modTime=" + modTime)
                .add("tenantId='" + tenantId + "'")
                .add("tenantName='" + tenantName + "'")
                .add("resId=" + Arrays.toString(resId))
                .toString();
    }
}
